package org.yuanqiframework.yuanqi.web.mq.handle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

@Slf4j
public class ReturnsCallback implements RabbitTemplate.ReturnsCallback {
    /**
     * 消息失败回调方法
     * 从交换机到队列
     *
     * @param returned
     */
    @Override
    public void returnedMessage(ReturnedMessage returned) {
        log.error("消息路由失败！交换机：{}，路由键：{}，消息：{}",
                returned.getExchange(), returned.getRoutingKey(), new String(returned.getMessage().getBody()));
    }
}
